-
Notifications
You must be signed in to change notification settings - Fork 0
feat(mbp): recovery consolidate from wallet address #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e45c55c to
f4f0859
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for recovering consolidation sweeps from TRX and Solana wallet addresses via a new /recoveryConsolidations endpoint.
- Extend
coinUtilsto recognize Sol and TRX coins. - Define a new API spec, router entry, handler, and client interfaces for the recovery consolidations endpoint.
- Add end‐to‐end tests covering TRX and Solana consolidation recovery flows.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/shared/coinUtils.ts | Added isSolCoin and isTrxCoin helpers. |
| src/api/master/routers/masterApiSpec.ts | Declared new request/response types and route spec. |
| src/api/master/handlers/recoveryConsolidationsWallet.ts | Implemented handler logic for TRX/Sol consolidation recovery. |
| src/api/master/clients/enclavedExpressClient.ts | Extended RecoveryMultisigOptions to accept MPC transaction types. |
| src/tests/api/master/recoveryConsolidationsWallet.test.ts | Added tests for TRX and Solana consolidation recovery. |
Comments suppressed due to low confidence (1)
src/api/master/routers/masterApiSpec.ts:189
- Using
t.anyfor the signed transactions response is too permissive. Consider defining a more specific transaction schema to improve validation and client typing.
signedTxs: t.array(t.any), // Array of fully signed transactions
| ); | ||
|
|
||
| // 1. Build unsigned consolidations | ||
| if (isSolCoin(sdkCoin)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for having these if conditions. If the recoverConsolidations method is implemented for a coin, we should continue. If not, then we should throw an error saying it is not supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| txs = result.transactions; | ||
| } | ||
|
|
||
| console.log(txs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use logger.debug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| const signedTxs = []; | ||
| try { | ||
| for (const tx of txs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are there multiple unsigned sweeps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return result from sdkCoin.recoverConsolidations is transaction array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess they are all txs from receive address -> base.
| userKey: userPub, | ||
| backupKey: backupPub, | ||
| bitgoKey, | ||
| durableNonces: req.decoded.durableNonces!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of doing this; just do an if check to throw an error if coin is sol and req.decoded.durableNonces is undefined. But call sdkCoin.recoverConsolidations( only once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
f679941 to
8aff26f
Compare
The base branch was changed.
| const signedTxs = []; | ||
| try { | ||
| for (const tx of txs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess they are all txs from receive address -> base.
| const result = await (sdkCoin as any).recoverConsolidations({ | ||
| ...req.decoded, | ||
| userKey: userPub, | ||
| backupKey: backupPub, | ||
| bitgoKey, | ||
| durableNonces: req.decoded.durableNonces, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't cast to any, use the appropriate coin classes that support recoverConsolidations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| if (typeof (sdkCoin as any).recoverConsolidations !== 'function') { | ||
| throw new Error(`recoverConsolidations is not supported for coin: ${coin}`); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here. create a type guard instead that validates sdkCoin supports recoverConsolidations and returns an extended BaseCoin type.
| durableNonces: t.union([ | ||
| t.undefined, | ||
| t.type({ | ||
| publicKeys: t.array(t.string), | ||
| secretKey: t.string, | ||
| }), | ||
| ]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can use optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| startingScanIndex: t.union([t.undefined, t.number]), // Optional | ||
| endingScanIndex: t.union([t.undefined, t.number]), // Optional | ||
| seed: t.union([t.undefined, t.string]), // Optional (Sol) | ||
| tokenContractAddress: t.union([t.undefined, t.string]), // Optional (TRX/Sol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can just use optional(t.x)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
| userPub: t.string, | ||
| backupPub: t.string, | ||
| bitgoKey: t.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need all 3 values, the pub for them all is going to be the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
acaef72 to
5675ff4
Compare
ff6ecf8 to
88eac6b
Compare
5675ff4 to
41f7b16
Compare
75b87bc to
57775b3
Compare
| bitgoKey: bitgoPub, | ||
| }); | ||
|
|
||
| console.log(`Recovery consolidations result: ${JSON.stringify(result)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think we need this.
recovery consolidate from wallet address
TASKS: WP-5143